package communication;


import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import lejos.pc.comm.NXTComm;
import lejos.pc.comm.NXTCommFactory;
import lejos.pc.comm.NXTConnector;
import lejos.pc.comm.NXTInfo;



public class BTConnection implements Runnable {
	private DisWrap disw;
	private NXTConnector connector;
	
    public BTConnection() {
    	this.disw = new DisWrap();
    }
    public void run() {
    	try{
    		connector = new NXTConnector();
    		connector.connectTo("Jos","00:16:53:07:A6:2D", NXTCommFactory.BLUETOOTH);
    		
    		disw.setDis(connector.getDataIn());
    		disw.setDos(connector.getDataOut());
//    		try {
//    			NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
//    			NXTInfo nxtInfo = new NXTInfo(NXTCommFactory.BLUETOOTH,"Jos", "00:16:53:07:A6:2D");
//    			nxtComm.open(nxtInfo);
//    			OutputStream os = nxtComm.getOutputStream();
//    			disw.setDos(new DataOutputStream(os));
//    			InputStream is = nxtComm.getInputStream();
//    			disw.setDis(new DataInputStream(is));
//    		} catch(Exception e) {
//    			System.out.println(" nxtcommexception in btconnection");
//    		}

    	}
    	catch(Exception e){}
    }
    
    public DisWrap GetDisWrap()
    {
    	return disw;
    }

}
